package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Sale;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.service.ISaleService;
import cn.wolfcode.crm.util.JsonResult;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("sale")
public class SaleController {
    @Autowired
    private ISaleService saleService;
    @RequestMapping("")
    public String index(){
        return  "sale/list";
    }
    @RequestMapping("save")
    @ResponseBody
    public JsonResult save(Sale sale){

        JsonResult result = new JsonResult();
        try {
            saleService.save(sale);
        }catch (Exception e) {
            result = new JsonResult("保存失败");
            e.printStackTrace();
        }
       return result;
    }
    @RequestMapping("select")
    @ResponseBody
    public JsonResult select(){
        JsonResult result = new JsonResult();
        try {
            saleService.select();
        }catch (Exception e) {
            result = new JsonResult("取出失败");
            e.printStackTrace();
        }
        return result;
    }

    @RequestMapping("saleanalyze")
    @ResponseBody
    public PageResult list(QueryObject qo){
        PageResult result = saleService.query(qo);

        return result;
    }
    @RequestMapping("memberConsumeInfo")
    @ResponseBody
    public PageResult memberConsumeInfo(QueryObject qo){
        PageResult result = saleService.queryList(qo);

        return result;
    }
    @RequestMapping("selectData")
    @ResponseBody
    public PageResult selectData(QueryObject qo){
        PageResult result = saleService.selectData(qo);

        return result;
    }

}
